<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Struts2 - JSON Example</title>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/base.js"></script>
<style type="text/css">

 table, th , td  {
    border: 1px solid grey;
    border-collapse: collapse;
    padding: 5px;
}
table tr:nth-child(odd)	{
    background-color: #f1f1f1;
}
table tr:nth-child(even) {
    background-color: #ffffff;
}
 
</style>
</head>
<body>
<!-- <h2>Struts2 json &amp; jquery - Demo</h2> -->
<a href="javascript:sendJSONData()">Write</a>
<br>
<a href="#" onclick="data();">Read</a>

<div id="id01"></div>


<script type="text/javascript">

function data(){
	var out = "<table>";
	$.getJSON("readJSON.action", function(res) {
	var i;

//console.log(" "+res.data[i].name+"-"+res.data[i].id+"-"+res.data[i].active+"-"+res.data[i].date);

for(i = 0; i < res.data.length; i++) {
    out += "<tr><td>" + 
    res.data[i].name +
    "</td><td>" +
    res.data[i].id +
    "</td><td>" +
    res.data[i].active+
    "</td><td>"+
    res.data[i].date+
    "</tr>";
}
	out += "</table>"
		document.getElementById("id01").innerHTML = out;
});
	
	
}
</script>

</body>